package com.example.work3;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity2 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        Button yes = findViewById(R.id.yes);
        Button no = findViewById(R.id.no);
        Button btnBack = findViewById(R.id.btnBack);
        Intent intent = getIntent();
        String name = intent.getStringExtra("name");
        if(name != null)
            setTitle("欢迎: "+name);

        no.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent returnIntent = new Intent();
                returnIntent.putExtra("result","NO");
                returnIntent.putExtra("selectedOption","NO");
                setResult(RESULT_OK,returnIntent);
                finish();
            }
        });
        btnBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                finish();
            }
        });
        yes.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent returnIntent = new Intent();
                returnIntent.putExtra("result","YES");
                returnIntent.putExtra("selectedOption","YES");
                setResult(RESULT_OK,returnIntent);
                finish();
            }
        });
    }
}




















